<?php

namespace app\modules\admin\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\Expression;

/**
 * This is the model class for table "article".
 *
 * @property string $article_id
 * @property string $article_title
 * @property string $summary
 * @property string $create_at
 * @property string $update_at
 */
class Article extends \yii\db\ActiveRecord
{
    public $content;
    public $img;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'article';
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'create_at',
                'updatedAtAttribute' => 'update_at',
                'value' => new Expression('NOW()'),
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['content'], 'required'],
            [['create_at', 'update_at'], 'safe'],
            [['article_title'], 'string', 'max' => 64],
            [['summary'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'article_id' => Yii::t('app', 'Article ID'),
            'article_title' => Yii::t('app', '标题'),
            'summary' => Yii::t('app', '简介'),
            'content' => Yii::t('app', '内容'),
            'img' => Yii::t('app', '首页图片'),
            'create_at' => Yii::t('app', '创建时间'),
            'update_at' => Yii::t('app', '更新时间'),
        ];
    }

}
